﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vowei.Core.Models;
using System.Collections;
using System.ComponentModel.DataAnnotations;

namespace Vowei.Core.Models
{
    public class StakeHolder : IUser
    {
        [Display(Name = "用户域帐号")]
        public string UserName { get; set; }

        [Required]
        [Display(Name = "电子邮件")]
        public string Email
        {
            get;
            set;
        }

        [Display(Name = "姓名")]
        public string DisplayName
        {
            get;
            set;
        }

        public int SharePointId
        {
            get;
            set;
        }

        public string GetIdentifier()
        {
            return string.IsNullOrEmpty(UserName) ? Email : UserName;
        }
    }
    
    public class Employee : ITable, IUser
    {
        public Employee()
        {
            OnboardDate = DateTime.Now;
            ID = Guid.NewGuid();
        }

        public int SharePointId
        {
            get;
            set;
        }

        [Display(Name = "用户域帐号")]
        public string UserName { get; set; }

        [Required]
        [Display(Name = "电子邮件")]
        public string Email
        {
            get;
            set;
        }

        [Display(Name = "姓名")]
        public string DisplayName
        {
            get;
            set;
        }

        public string GetIdentifier()
        {
            return string.IsNullOrEmpty(UserName) ? Email : UserName;
        }

        [Display(Name = "直线经理")]
        public Employee ReportTo
        {
            get;
            set;
        }

        public string ReportToEmail { get; set; }


        [Display(Name = "职务")]
        public string Title
        {
            get;
            set;
        }

        [Display(Name = "部门")]
        public string Department
        {
            get;
            set;
        }

        [Display(Name = "职称")]
        public string Level
        {
            get;
            set;
        }

        [Display(Name = "电话")]
        public string Telephone
        {
            get;
            set;
        }

        [Display(Name = "入职日期")]
        public DateTime OnboardDate
        {
            get;
            set;
        }

        [Display(Name = "离职日期")]
        public DateTime? PotentialQuitDate
        {
            get;
            set;
        }

        [Display(Name = "确认离职")]
        public bool IsConfirmed
        {
            get;
            set;
        }

        [Display(Name = "替补人员")]
        public Employee Replacement
        {
            get;
            set;
        }

        [Display(Name = "公司")]
        public string Company
        {
            get;
            set;
        }

        public Guid ID
        {
            get;
            set; 
        }
    }

    internal class ByEmailEmployeeComparer : IComparer<Employee>
    {
        public int Compare(Employee x, Employee y)
        {
            if (x == null && y == null)
                return 0;
            else if (x != null && y == null)
                return 1;
            else if (x == null && y != null)
                return -1;
            else
                return string.Compare(x.Email, y.Email, true);
        }
    }

    internal class ByDisplayNameEmployeeComparer : IComparer<Employee>
    {
        public int Compare(Employee x, Employee y)
        {
            if (x == null && y == null)
                return 0;
            else if (x != null && y == null)
                return 1;
            else if (x == null && y != null)
                return -1;
            else
                return string.Compare(x.DisplayName, y.DisplayName, true);
        }
    }
}
